/*
 *  Class name: Account.java
 *  Version: 1.0
 *  Date: 21.6.2014
 */
package cz.morosystems.personwebmanager.persistencelayer.entities;

import java.io.Serializable;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author Michal Ďuriš
 */
@Entity
public class Account implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @NotNull
    @Size(min = 1, max = 20,
          message = "Názov účtu musí byť zadaný! (max. 20 znakov)")
    @Column(length = 20, nullable = false)
    private String name;

    @Size(max = 4)
    @Column(length = 4)
    private String accountPrefix;

    @NotNull
    @Size(min = 1, max = 10,
          message = "Číslo účtu musí byť zadané! (max. 10 znakov)")
    @Column(length = 10, nullable = false)
    private String accountNumber;

    @NotNull
    @Size(min = 1, max = 4,
          message = "Kód banky musí byť zadaný! (max. 4 znaky)")
    @Column(length = 4, nullable = false)
    private String bankCode;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAccountPrefix() {
        return accountPrefix;
    }

    public void setAccountPrefix(String accountPrefix) {
        this.accountPrefix = accountPrefix;
    }

    public String getAccountNumber() {
        return accountNumber;
    }

    public void setAccountNumber(String accountNumber) {
        this.accountNumber = accountNumber;
    }

    public String getBankCode() {
        return bankCode;
    }

    public void setBankCode(String bankCode) {
        this.bankCode = bankCode;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 59 * hash + Objects.hashCode(this.id);
        hash = 59 * hash + Objects.hashCode(this.name);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {

        if (obj == null) {
            return false;
        }

        if (!(obj instanceof Account)) {
            return false;
        }

        final Account other = (Account) obj;

        if (!Objects.equals(this.id, other.id)) {
            return false;
        }

        return Objects.equals(this.name, other.name);
    }

    @Override
    public String toString() {
        return "cz.morosystems.personwebmanager.persistencelayer.entities.Account[ id=" + id + " ]";
    }

}
